package editors.objectedit;
import graphics.objects.GraphicsObject;
import tools.Help;
import tools.Point;
public class PointTransformer {
	Point scale;
	Point offset;
	BoundingBox newBox, oldBox;
	public PointTransformer(BoundingBox newBox, BoundingBox oldBox) {
		this.newBox = newBox;
		this.oldBox = oldBox;
		scale = new Point((newBox.maxX - newBox.minX) / (oldBox.maxX - oldBox.minX), (newBox.maxY - newBox.minY) / (oldBox.maxY - oldBox.minY));
		offset = new Point(newBox.minX - oldBox.minX, newBox.minY - oldBox.minY);
	}
	public Point transform(Point p) {
		return new Point(newBox.minX + (p.x - oldBox.minX) * scale.x, newBox.minY + (p.y - oldBox.minY) * scale.y);
	}
	public void transformGraphicsObject(GraphicsObject o) {
		o.node.scale.x *= scale.x;
		o.node.scale.y *= scale.y;
		o.node.pos = transform(o.node.pos);
	}
	public Point scale(Point p) {
		p.x *= scale.x;
		p.y *= scale.y;
		return p;
	}
}